package com.liang.file;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;

public class FileText4 {
    public static void main(String[] args) throws IOException {
        File file = new File("D:\\itheima\\fff");
        if (!file.exists()) {
            file.mkdirs();
        }
        File file1 = new File(file, "a.txt");

        file1.createNewFile();
    }

    public static class FileText6 {
        public static void main(String[] args) {
            File file = new File("day_12");
            HashMap<String, Integer> hm = new HashMap<>();

            method(hm,file);

            System.out.println(hm);
        }

        public static void method(HashMap<String, Integer> hm,File file) {
            File[] files = file.listFiles();
            if(files!=null){
                for (File f : files) {
                    String name = f.getName();
                    String[] split = name.split("\\.");
                    if (split.length == 2) {
                        if (hm.containsKey(split[1])) {
                            Integer count = hm.get(split[1]);
                            count++;
                            hm.put(split[1], count);
                        }else{
                            hm.put(split[1], 1);
                        }
                    }else{
                        method(hm,f);
                    }
                }
            }
        }
    }
}
